package com.goodving.guli.bt.profile.scale;

import android.os.Environment;
import android.util.Log;

import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by john on 2015/11/25.
 */
public class GuliLog { // C1496r
    public static int f7544a = 0;
    public static int f7545b = 0;
    public static int f7546c = 0;
    public static int f7547d = 0;
    public static int printLevel = 0;
    public static boolean f7549f = false;
    public static int f7550g = 0;
    private static final int f7551h = 20971520;
    private static boolean f7552i = true;//false;
    private static final boolean f7553j = true;
    private static final boolean f7554k = true;
    private static final boolean f7555l = true;
    private static final boolean f7556m = true;
    private static final boolean f7557n = true;
    private static boolean enableTrace = false;
    private static boolean enableAssert = false;
    private static boolean enableDebugLock = false;
    private static final boolean f7561r = true;
    private static final boolean f7562s = false;
    private static final String debug = "DEBUG"; // f7563t

    static {
        f7544a = -1;
        f7545b = 0;
        f7546c = 1;
        f7547d = 2;
        printLevel = f7545b;
        f7549f = f7561r;
        f7550g = 2;
        f7552i = true;
        enableTrace = f7561r;
        enableAssert = f7561r;
        enableDebugLock = f7561r;
    }

    public static void m12348a() {
        File file = new File(Environment.getExternalStorageDirectory() + "/mili_log.txt");
        if (file.exists()) {
            file.delete();
        }
    }

    public static void ASSERT_NOT_NULL(Object obj) { // m12349a
        if (enableAssert && obj == null) {
            GuliLog.m12352a(debug, ">>> `NOT NULL` ASSERTION FAILED <<<", 0, 'e');
        }
    }

    public static void m12350a(String str) {
        GuliLog.m12352a(debug, str, 0, 'd');
    }

    public static void tracePrintError(String str, String str2) { // m12351a
        if (printLevel > f7544a) {
            Log.e(str, GuliLog.stackTracePrint() + str2);
        }
    }

    private static void m12352a(String str, String str2, int i, char c) {
        if (f7552i) {
            String name = Thread.currentThread().getName();
            StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[i + 4];
            String className = stackTraceElement.getClassName();
            className = className.substring(className.lastIndexOf(46) + 1);
            String methodName = stackTraceElement.getMethodName();
            name = "[" + name + "]" + "<" + className + C4220a.ci + methodName + C4220a.ci + stackTraceElement.getLineNumber() + "> ";
            String str3 = C3657a.f18328f;
            switch (c) {
                case C4220a.ar /*100*/:
                    Log.d(str, name + str2 + str3);
                    break;
                case 101 /*101*/:
                    Log.e(str, name + str2 + str3);
                    break;
                case 105 /*105*/:
                    Log.i(str, name + str2 + str3);
                    break;
                case 'v':
                    Log.v(str, name + str2 + str3);
                    break;
                case 'w':
                    Log.w(str, name + str2 + str3);
                    break;
                default:
                    break;
            }
        }
    }

    public static void m12353a(String str, String str2, Throwable th) {
        if (printLevel > f7544a) {
            Log.e(str, GuliLog.stackTracePrint() + str2, th);
        }
    }

    public static void ASSERTION_RUN_ON_THREAD(Thread thread) {
        if (enableAssert && thread != null && Thread.currentThread().getId() != thread.getId()) {
            GuliLog.m12352a(debug, ">>> `RUN ON THREAD` ASSERTION FAILED <<<", 0, 'e');
        }
    }

    public static void ASSERTION_TRUE(boolean z) {
        if (enableAssert && !z) {
            GuliLog.m12352a(debug, ">>> `TRUE` ASSERTION FAILED <<<", 0, 'e');
        }
    }

    public static void m12356a(boolean z, boolean z2) {
        printLevel = z ? f7545b : f7544a;
        GuliLog.m12366c(z);
        f7549f = z2;
    }

    public static void ENABLE(boolean z, boolean z2, boolean z3) { // m12357a
        f7552i = f7561r;
        enableTrace = z;
        enableAssert = z2;
        enableDebugLock = z3;
        GuliLog.debugIcon();
        GuliLog.INFO("         ENABLE_VERBOSE: TRUE");
        GuliLog.INFO("           ENABLE_DEBUG: TRUE");
        GuliLog.INFO("            ENABLE_INFO: TRUE");
        GuliLog.INFO("            ENABLE_WARN: TRUE");
        GuliLog.INFO("           ENABLE_ERROR: TRUE");
        GuliLog.INFO("           ENABLE_TRACE: " + (enableTrace ? "TRUE" : "FALSE"));
        GuliLog.INFO("          ENABLE_ASSERT: " + (enableAssert ? "TRUE" : "FALSE"));
        GuliLog.INFO("      ENABLE_DEBUG_LOCK: " + (enableDebugLock ? "TRUE" : "FALSE"));
        GuliLog.INFO("        ENABLE_LOG_META: TRUE");
        GuliLog.INFO("  ENABLE_LOG_TRACE_INFO: FALSE");
    }

    public static void ASSERT_NULL(Object obj) { // m12358b
        if (enableAssert && obj != null) {
            GuliLog.m12352a(debug, ">>> `NULL` ASSERTION FAILED <<<", 0, 'e');
        }
    }

    public static void m12359b(String str) {
        if (enableDebugLock) {
            GuliLog.m12352a(debug, "LOCK#" + str, 0, 'v');
        }
    }

    public static void m12360b(String str, String str2) {
        if (f7549f) {
            File file = new File(Environment.getExternalStorageDirectory() + "/mili_log.txt");
            if (file.exists() && file.length() > 20971520) {
                file.delete();
            }
            try {
                FileWriter fileWriter = new FileWriter(file, f7561r);
                fileWriter.write(GuliLog.m12377g() + "  " + str + "  " + str2 + "\n");
                fileWriter.close();
            } catch (IOException e) {
            }
        }
    }

    public static void m12361b(String str, String str2, Throwable th) {
        if (printLevel > f7544a && printLevel < f7547d) {
            Log.w(str, str2, th);
        }
    }

    public static void m12362b(boolean z) {
        printLevel = z ? f7545b : f7544a;
        f7549f = z;
        GuliLog.m12366c(z);
    }

    public static boolean m12363b() {
        return (printLevel <= f7544a || printLevel >= f7547d) ? f7562s : f7561r;
    }

    public static void ERROR(String str) { // m12364c
        GuliLog.m12352a(debug, str, 0, 'e');
    }

    public static void m12365c(String str, String str2) {
        if (f7549f) {
            File file = new File(Environment.getExternalStorageDirectory() + "/hr_running.txt");
            if (file.exists() && file.length() > 20971520) {
                file.delete();
            }
            try {
                FileWriter fileWriter = new FileWriter(file, f7561r);
                fileWriter.write(str2 + "\n");
                fileWriter.close();
            } catch (IOException e) {
            }
        }
    }

    public static void m12366c(boolean z) {
        f7552i = z;
        enableTrace = z;
        enableAssert = z;
        enableDebugLock = z;
    }

    public static boolean m12367c() {
        return f7549f;
    }

    public static void m12368d() {
        if (printLevel > f7544a && printLevel < f7546c) {
            StackTraceElement stackTraceElement = new Exception().getStackTrace()[f7550g - 1];
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(stackTraceElement.getMethodName());
            stringBuilder.append(C4220a.ci);
            stringBuilder.append(stackTraceElement.getLineNumber());
            String className = stackTraceElement.getClassName();
            Log.i(className.substring(className.lastIndexOf(".") + 1), stringBuilder.toString());
        }
    }

    public static void INFO(String str) { // m12369d
        GuliLog.m12352a(debug, str, 0, 'i');
    }

    public static void m12370d(String str, String str2) {
        if (printLevel > f7544a && printLevel < f7546c) {
            Log.i(str, GuliLog.stackTracePrint() + str2);
        }
        GuliLog.m12360b(str, str2);
    }

    public static void m12371e() {
        if (enableTrace) {
            GuliLog.m12352a(debug, "<<<<====", 0, 'v');
        }
    }

    public static void VERBOSE(String str) { // m12372e
        GuliLog.m12352a(debug, str, 0, 'v');
    }

    public static void tracePrintInfo(String str, String str2) { // m12373e
        if (printLevel > f7544a && printLevel < f7546c) {
            Log.i(str, GuliLog.stackTracePrint() + str2);
        }
    }

    public static String stackTracePrint() { // m12374f
        StackTraceElement stackTraceElement = new Exception().getStackTrace()[f7550g];
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<");
        String className = stackTraceElement.getClassName();
        stringBuilder.append(className.substring(className.lastIndexOf(".") + 1));
        stringBuilder.append(C4220a.ci);
        stringBuilder.append(stackTraceElement.getMethodName());
        stringBuilder.append(C4220a.ci);
        stringBuilder.append(stackTraceElement.getLineNumber());
        stringBuilder.append("> ");
        return stringBuilder.toString();
    }

    public static void WARN(String str) { // m12375f
        GuliLog.m12352a(debug, str, 0, 'w');
    }

    public static void m12376f(String str, String str2) {
        if (printLevel > f7544a && printLevel < f7546c) {
            for (int i = 0; i <= str2.length() / C3515h.f17660E; i++) {
                int i2 = i * C3515h.f17660E;
                int i3 = (i + 1) * C3515h.f17660E;
                if (i3 > str2.length()) {
                    i3 = str2.length();
                }
                Log.i(str, GuliLog.stackTracePrint() + str2.substring(i2, i3));
            }
        }
    }

    private static String m12377g() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
    }

    public static void tracePrintWarn(String str, String str2) {
        if (printLevel > f7544a && printLevel < f7547d) {
            Log.w(str, GuliLog.stackTracePrint() + str2);
        }
    }

    private static void debugIcon() { // m12379h
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MM.:  .:'   `:::  .:`MMMMMMMMMMM|`MMM'|MMMMMMMMMMM':  .:'   `:::  .:'.MM");
        GuliLog.INFO("MMMM.     :          `MMMMMMMMMM  :*'  MMMMMMMMMM'        :        .MMMM");
        GuliLog.INFO("MMMMM.    ::    .     `MMMMMMMM'  ::   `MMMMMMMM'   .     ::   .  .MMMMM");
        GuliLog.INFO("MMMMMM. :   :: ::'  :   :: ::'  :   :: ::'      :: ::'  :   :: ::.MMMMMM");
        GuliLog.INFO("MMMMMMM    ;::         ;::         ;::         ;::         ;::   MMMMMMM");
        GuliLog.INFO("MMMMMMM .:'   `:::  .:'   `:::  .:'   `:::  .:'   `:::  .:'   `::MMMMMMM");
        GuliLog.INFO("MMMMMM'     :           :           :           :           :    `MMMMMM");
        GuliLog.INFO("MMMMM'______::____      ::    .     ::    .     ::     ___._::____`MMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMM`---._ :: ::'  :   :: ::'  _.--::MMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMM::.         ::  .--MMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-.     ;::-MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM. .:' .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.   .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\\ /MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMVMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM .:ZylvanaS:. MM");
        GuliLog.INFO("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
    }
}

